<?php
include_once '../config/conexao.php';
include_once '../funcao/util.php';
$cod = $_POST['cod'];
$sql_post = $conn->query ( "select * from postagem where estado = 'C' and codigo = $cod" );
$post = $sql_post->fetch ( PDO::FETCH_ASSOC );
if ($sql_post->rowCount () > 0) {
	?>
<h3 class="page-header">
	<b><?php echo $post['titulo'] ?>
	</b><br /> <small>by <?php echo $post['usuario'] ?> em <?php echo dataBancoByPt($post['data']); ?>
	</small>
</h3>
<feldset class="fildset">
<legend>Resumo</legend>
<?php echo $post['resumo'] ?>
</feldset>
<legend>Conteudo</legend>
<?php echo $post['conteudo'] ?>
</feldset>
<div class="panel-footer">
	<div class="panel panel-default">
		<div class="panel-body coments">
			<small> <?php
			$sql_coments = $conn->query("select * from comentario where estado = 'N' and post = ".$post['codigo']." order by data");
			while($coment = $sql_coments->fetch(PDO::FETCH_ASSOC)){
				?>
				<div codigo="<?php echo $coment['codigo']?>">
					<h5 class="page-header">
						<b><?php echo $coment['usuario']?> </b><br /> <small> comentou em
						<?php echo dataBancoByPt($coment['data']);?> </small>
					</h5>
					<p>
					<?php echo $coment['conteudo'];?>
					</p>
					<br />
				</div> <?php }
				if($sql_coments->rowCount() == 0){
					echo '<p>Não existe Comentario</p>';
				}
				?> </small>
		</div>
	</div>
</div>
	<?php } ?>